<template lang="pug">
  .clearfix
    Modal(
      v-model="isShowCreateFileModal"
      title="新建文件夹"
      class-name="vertical-center-modal"
    )
      Form.ivu-row(ref="formData" :model="formData" :rules="rules" :label-width="120")
        FormItem.form-item.ivu-col.pr-20(v-for="(item, index) of formItem" :label="item.label" :key="index" :class="item.style" :prop="item.prop")
          template(v-if="item.type === 'select'")
            Select(v-model="formData[item.model]" :placeholder="item.placeholder")
              Option(
                v-for="(c_item, index) in arrListDown[item.options]"
                :value="c_item.key"
                :key="index"
              ) {{ c_item.value }}
          template(v-if="item.type === 'input'")
            Input(v-model="formData[item.model]" :placeholder="item.placeholder")
          template(v-if="item.type === 'radio'")
            RadioGroup(type="button" v-model="formData[item.model]")
              Radio.display-inline-block(v-for="(c_item,idx) of item.radioArr" :label="c_item.value" :key="idx") {{c_item.label}}
          template(v-if="item.type === 'datePicker'")
            DatePicker(v-model="formData[item.model]" :placeholder="item.placeholder1" type="month")

      .clearfix(slot="footer")
        Button(type="text" @click="cancel") 取消
        Button(type="primary" @click="handleSubmit") 确定
</template>

<script>
import { PolicySupportApi } from '@/api/PolicySupport.api.js'
export default {
  name: '',

  props: {
    PSID: {
      type: String,
      default: 'local'
    }
  },

  data () {
    return {
      isShowCreateFileModal: false,
      formData: {
        dirname: ''
      },
      formItem: [
        { type: 'input', label: '文件名称', placeholder: '请输入文件名称', prop: 'dirname', model: 'dirname', style: 'ivu-col-span-24' }

      ],
      rules: {
        // IdCardNo: [
        //   { type: "string", message: '请输入正确的身份证号码', pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/ }
        // ]
      },
      arrListDown: {
        tempOps: []
      }
      // PSID: 'local'
    }
  },

  watch: {
  },

  mounted () {
  },

  methods: {
    cancel () {
      this.isShowCreateFileModal = false
    },

    async handleSubmit () {
      console.log('this.formData: ', { ...this.formData, ...{ PSID: this.PSID } })
      let res = await PolicySupportApi.createDir({ ...this.formData, ...{ PSID: this.PSID } })
      console.log('res: ', res)
      if (res.data.code === 200 && res.data.success) {
        this.$Message.success(res.data.message)
        this.$emit('query')
        this.cancel()
      } else {
        
        this.$Message.error({
          content: res.data.message,
          duration: 10,
          closable: true
        })
      }
    }
  }
}
</script>

<style lang="less" scope>
</style>
